Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix flaky Local SDK test #1586

Merged
merged 2 commits into from
May 26, 2020

Conversation

aLekSer
Copy link
Collaborator

@aLekSer aLekSer commented May 26, 2020

What type of PR is this?

Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespace from that line:

/kind breaking
/kind bug
/kind cleanup
/kind documentation
/kind feature

/kind hotfix

What this PR does / Why we need it:
Fix LocalSDK test which is flaky.

Which issue(s) this PR fixes:

Special notes for your reviewer:

There is still a timeout possible here:

assertWatchUpdate(t, stream, "bar", func(gs *sdk.GameServer) interface{} {

@aLekSer aLekSer added the area/tests Unit tests, e2e tests, anything to make sure things don't break label May 26, 2020
@@ -125,6 +125,8 @@ func TestLocalSDKServerSetLabel(t *testing.T) {
}

for k, v := range fixtures {
k := k
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've seen this before, and I feel like I've done similar to fix previous issues and I forget the reason for it. Can we add a note explaining?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I will do (there is a gocritic linter article about this), btw on the multiple runs still get some errors. Will update the test one more time

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was not gocritic, but https://github.com/kyoh86/scopelint and it is obsolete, with two successors.

@aLekSer
Copy link
Collaborator Author

aLekSer commented May 26, 2020

Strange enough I have received error here, something wrong with runtime.Features:

panic: runtime error: invalid memory address or nil pointer dereference [recovered]
	panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x1e977ec]

goroutine 541 [running]:
testing.tRunner.func1(0xc00040b300)
	/usr/local/Cellar/go/1.13.1/libexec/src/testing/testing.go:874 +0x3a3
panic(0x1ffa7e0, 0x2e23980)
	/usr/local/Cellar/go/1.13.1/libexec/src/runtime/panic.go:679 +0x1b2
agones.dev/agones/pkg/sdkserver.TestLocalSDKServerPlayerConnectAndDisconnect.func2(0xc00040b300)
	/Users/alexander.apalikov/go/src/github.com/agones/agones/pkg/sdkserver/localsdk_test.go:460 +0x61c
testing.tRunner(0xc00040b300, 0xc0008ea210)
	/usr/local/Cellar/go/1.13.1/libexec/src/testing/testing.go:909 +0xc9
created by testing.(*T).Run
	/usr/local/Cellar/go/1.13.1/libexec/src/testing/testing.go:960 +0x350
exit status 2
FAIL	agones.dev/agones/pkg/sdkserver	13.300s

@markmandel
Copy link
Member

Strange enough I have received error here, something wrong with runtime.Features:

Seems like the feature flag got flipped mid test? Is there a test somewhere that's not been locked appropriately I wonder.

I wonder if we want to add some debug logging here and here to help with picking this up?

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 35ca3c2b-c34d-4eca-9e42-c5600b8fbe21

The following development artifacts have been built, and will exist for the next 30 days:

A preview of the website (the last 30 builds are retained):

To install this version:

  • git fetch https://github.com/GoogleCloudPlatform/agones.git pull/1586/head:pr_1586 && git checkout pr_1586
  • helm install ./install/helm/agones --namespace agones-system --name agones --set agones.image.tag=1.6.0-d30668c

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 050b18ef-9013-46e9-b506-9c43c8a8c039

The following development artifacts have been built, and will exist for the next 30 days:

A preview of the website (the last 30 builds are retained):

To install this version:

  • git fetch https://github.com/GoogleCloudPlatform/agones.git pull/1586/head:pr_1586 && git checkout pr_1586
  • helm install ./install/helm/agones --namespace agones-system --name agones --set agones.image.tag=1.6.0-76b69bc

@aLekSer
Copy link
Collaborator Author

aLekSer commented May 26, 2020

Will add this comment here:

	runtime.FeatureTestMutex.Lock()
	defer runtime.FeatureTestMutex.Unlock()
	for k, v := range fixtures {
		k := k
		v := v
		t.Run(k, func(t *testing.T) {
			t.Parallel()
			runtime.FeatureTestMutex.Lock()
			defer runtime.FeatureTestMutex.Unlock()
...

This one above would not have a deadlock and without t.Parallel() it has. So nested parallel tests could use different variables set.

@aLekSer
Copy link
Collaborator Author

aLekSer commented May 26, 2020

I am running all tests in pkg/sdkserver/localsdk_test.go for 2k times.

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: a621a926-f4e1-4968-94cd-c27899d6a23a

The following development artifacts have been built, and will exist for the next 30 days:

A preview of the website (the last 30 builds are retained):

To install this version:

  • git fetch https://github.com/GoogleCloudPlatform/agones.git pull/1586/head:pr_1586 && git checkout pr_1586
  • helm install ./install/helm/agones --namespace agones-system --name agones --set agones.image.tag=1.6.0-0cc6037

t.Run(k, func(t *testing.T) {
t.Parallel()
Copy link
Collaborator Author

@aLekSer aLekSer May 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line leads to unpredictable behaviour. I assume we can add this back in a separate PR.

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 3221cbdb-084d-4482-b63b-3d0cd8963e10

The following development artifacts have been built, and will exist for the next 30 days:

A preview of the website (the last 30 builds are retained):

To install this version:

  • git fetch https://github.com/GoogleCloudPlatform/agones.git pull/1586/head:pr_1586 && git checkout pr_1586
  • helm install ./install/helm/agones --namespace agones-system --name agones --set agones.image.tag=1.6.0-095205f

Copy link
Member

@markmandel markmandel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice cleanup!

@google-oss-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: aLekSer, markmandel

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@markmandel markmandel merged commit 2f90dda into googleforgames:master May 26, 2020
@markmandel markmandel added this to the 1.6.0 milestone May 26, 2020
@aLekSer
Copy link
Collaborator Author

aLekSer commented May 26, 2020

One rare failed test still exist (1 out of 144 tests):

--- FAIL: TestLocal (0.00s)
    localsdk_test.go:67: 
        	Error Trace:	localsdk_test.go:67
        	Error:      	Not equal: 
        	            	expected: &sdk.GameServer_ObjectMeta{Name:"local", Namespace:"default", Uid:"1234", ResourceVersion:"v1", Generation:1, CreationTimestamp:1590521272, DeletionTimestamp:0, Annotations:map[string]string{"annotation":"true"}, Labels:map[string]string{"islocal":"true"}, XXX_NoUnkeyedLiteral:struct {}{}, XXX_unrecognized:[]uint8(nil), XXX_sizecache:0}
        	            	actual  : &sdk.GameServer_ObjectMeta{Name:"local", Namespace:"default", Uid:"1234", ResourceVersion:"v1", Generation:1, CreationTimestamp:1590521271, DeletionTimestamp:0, Annotations:map[string]string{"annotation":"true"}, Labels:map[string]string{"islocal":"true"}, XXX_NoUnkeyedLiteral:struct {}{}, XXX_unrecognized:[]uint8(nil), XXX_sizecache:0}
        	            	
        	            	Diff:
        	            	--- Expected
        	            	+++ Actual
        	            	@@ -1,2 +1,2 @@
        	            	-(*sdk.GameServer_ObjectMeta)(name:"local" namespace:"default" uid:"1234" resource_version:"v1" generation:1 creation_timestamp:1590521272 annotations:<key:"annotation" value:"true" > labels:<key:"islocal" value:"true" > )
        	            	+(*sdk.GameServer_ObjectMeta)(name:"local" namespace:"default" uid:"1234" resource_version:"v1" generation:1 creation_timestamp:1590521271 annotations:<key:"annotation" value:"true" > labels:<key:"islocal" value:"true" > )
        	            	 
        	Test:       	TestLocal

And localsdk_test.go:282 could timeout locally at least.

ilkercelikyilmaz pushed a commit to ilkercelikyilmaz/agones that referenced this pull request Oct 23, 2020
* Fix flaky Local SDK test

* Extend Watch update to wait for file update

Line 281 is flaky.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved area/tests Unit tests, e2e tests, anything to make sure things don't break lgtm size/S
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants